Skip to content

Add standalone XY stack downsampling utility#25

Open
msayr wants to merge 1 commit into
mainfrom
codex/add-utility-for-10x-downsample-in-x,y
Open

Add standalone XY stack downsampling utility#25
msayr wants to merge 1 commit into
mainfrom
codex/add-utility-for-10x-downsample-in-x,y

Conversation

@msayr

@msayr msayr commented Jul 9, 2026

Copy link
Copy Markdown
Owner

Motivation

  • Provide a small, focused utility to reproduce the inspection-store downsampling used by the Z-alignment pipeline without running alignment.
  • The tool must downsample only the Y and X axes while leaving Z unchanged so downstream Z-based processing is unaffected.
  • Preserve and adapt common spatial metadata (resolution/voxel_size/voxel_offset) so the downsampled store is compatible with existing pipelines.

Description

  • Added a new module emalign/downsample_stack_xy.py that implements a programmatic function downsample_stack_xy and a CLI entrypoint (python -m emalign.downsample_stack_xy).
  • Downsampling is performed per-slice using scipy.ndimage.zoom so the output shape is [z, y//factor, x//factor] and the Z axis is copied slice-for-slice untouched.
  • Spatial attributes resolution and voxel_size are multiplied by the factor while voxel_offset is integer-divided for XY, and .zattrs/.zgroup files are written to maintain Zarr compatibility.
  • The CLI supports --factor, --interpolation (linear or nearest) and --overwrite and defaults to a 10x downsample and sensible chunk sizes.

Testing

  • Compiled the module with python -m py_compile emalign/downsample_stack_xy.py and the compilation passed.
  • Ran a smoke test that created a temporary 3x20x30 TensorStore Zarr input and executed python -m emalign.downsample_stack_xy <src> <dst> -f 10 --interpolation nearest, and verified the output shape remained 3 in Z and became 2x3 in YX.
  • Verified that .zattrs on the output contains scaled resolution/voxel_size and adjusted voxel_offset; all automated checks succeeded.

Codex Task

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant